package com.midou.administration.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.midou.administration.bo.ToTheNumberOfDays;
import com.midou.administration.bo.UserBo;
import com.midou.administration.service.impl.CommentServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/administration/comment")
public class CommentController {
    @Autowired
    private CommentServiceImpl commentService;

    @RequestMapping("/queryComment")
    public Page queryComment(@RequestBody UserBo userBo){
        return commentService.queryComment(userBo);
    }

    /**
     * 返回平均分
     * @param buid
     * @return
     */
    @RequestMapping("/doBuidFindAVGStar")
    public int doBuidFindAVGStar(@RequestBody int buid){
        int AvgStar = this.commentService.doBuidFindAVGStar(buid);
        return AvgStar;
    }

    /**
     * 返回最近7天的平均分
     * @param id
     * @return
     */
    @RequestMapping("/doDayFindAvgStar")
    public List<ToTheNumberOfDays> doDayFindAvgStar(@RequestBody int id){
        List<ToTheNumberOfDays> list = commentService.doDayFindAvgStar(id);
        return list;
    }
}
